package indi.kider.server.applet.api;

import indi.kider.common.model.apabus.Rent;
import indi.kider.server.applet.service.RentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.vankid.common.model.base.CommonResponse;

import java.util.List;

@RestController
@RequestMapping(value = "rent")
public class RentController {

    @Autowired
    private RentService rentService;

    @PostMapping("app-rent/getTenantHouseInfo/{tenantId}")
    public CommonResponse<Rent> getTenantHouseInfo(@PathVariable String tenantId) {
        try {
            return CommonResponse.buildGetSuccessResponse(rentService.getTenantHouseInfo(tenantId));
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }

    @PostMapping("app-rent/getEmployeeTenantInfo/{houseId}")
    public CommonResponse<List<Rent>> getEmployeeTenantInfo(@PathVariable String houseId) {
        try {
            return CommonResponse.buildGetSuccessResponse(rentService.getEmployeeTenantInfo(houseId));
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }

}
